<?php
namespace mytp;

// Request 类负责获取请求信息
class Request {

  protected $pathinfo;

  public function pathinfo(){
    // 判断一下是否存在
    if(is_null($this->pathinfo)){
      $this->pathinfo = trim($this->server('PATH_INFO', ''), '/');
    }
    return $this->pathinfo;
  }

  public function server($name, $default = null){
    return isset($_SERVER[$name]) ? $_SERVER[$name] : $default;
  }

  public function post($name, $default = null){
    return isset($_POST[$name]) ? $_POST[$name] : $default;
  }
  
  public function get($name, $default = null){
    return isset($_GET[$name]) ? $_GET[$name] : $default;
  }
}
?>